package com.romeo_foxtrot.labs.webproxy;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RootServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3603725628277322791L;

	private static final Logger logger = LoggerFactory
			.getLogger(RootServlet.class);

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		logger.debug(req.getRequestURL().toString());
		if (req.getSession(false) == null) {
			logger.debug("redirecting...");
			req.getSession();
			resp.sendRedirect("");
		} else {
			logger.debug("forwarding...");
			getServletContext().getRequestDispatcher("/index.jsp").forward(req,
					resp);
		}

	}

}
